package com.hmjk.health.health;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.hmjk.health.HealthApp;
import com.hmjk.health.R;
import com.hmjk.health.background.DataManager;
import com.hmjk.health.setting.SettingActivity;
import com.hmjk.health.setting.SettingsConstants;
import com.hmjk.health.util.DEV_DATA;
import com.hmjk.health.util.HEALTH_KEY;
import com.hmjk.health.util.GlycoseData;
import com.hmjk.health.util.MULTI_USER_DEV_DATA;


import android.app.FragmentManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class HealthCardsOverViewActivity extends FragmentActivity implements OnClickListener, OnPageChangeListener{
	private final String TAG = HealthCardsActivity.class.getSimpleName();
	private HealthApp mApp = null;
	private MULTI_USER_DEV_DATA mCurAccount = null;
	private ProgressBar mLoadingProgress;
	private ViewPager mSlider;
	private FragmentStatePagerAdapter mAdapter;
	private boolean loaded = false;
//	private ArrayList<HealthCardFragment> mPages = new ArrayList<HealthCardFragment>();
//	private HashMap<String, HealthCardFragment> mFragmentMap = new HashMap<String, HealthCardFragment>();
//	private ArrayList<MULTI_USER_DEV_DATA> mAccountListData = new ArrayList<MULTI_USER_DEV_DATA>();
//	private ArrayList<DEV_DATA> mDevListData = new ArrayList<DEV_DATA>();
//	
	
    Fragment fragmentBloodSugar    =   null;  
    Fragment fragmentBloodPressure =   null; 
//    Fragment fragmentSleep         =    null;   
//    Fragment fragmentWeight        =    null;  
    Fragment fragmentTemperature   =     null;   
	
	
	
	
    private TextView  healthTabtitle;

	
    private TextView  healthTabBloodSugar;
    private TextView  healthTabPressure;
//    private TextView  healthTabSleep;
    private TextView  healthTabTemperature;
//    private TextView  healthTabWeight;
    
    private ArrayList<Fragment> fragmentsList;
    
    private int currIndex = 0;
    static final public int TATAL_TAB_INDEX = 3;// 5;
    private int bottomLineWidth;
    private int offset = 0;
    private int position_one;
    private int position_two;
    private int position_three;	
    private int position_four;
    private int position_five;	    
//	
    private ViewPager mPager;
    private ImageView ivBottomLine;   
    
    private String pageString;
    
	private void logd(String info){
		Log.d(TAG,info);
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		logd("onCreate");
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		mApp = (HealthApp)getApplication();
		
		Intent i = getIntent();
		
//		String tid = i.getStringExtra("tid");
//		mCurAccount = new MULTI_USER_DEV_DATA();
//		if(tid != null){
//			mCurAccount.id = tid.trim();
//		} 
		
       pageString  = (String)      i.getSerializableExtra(HealthCardFragment.BUNDLE_PARAM_SUB_TAB_ITEMS);  
       mCurAccount = (MULTI_USER_DEV_DATA)   i.getSerializableExtra(HealthCardFragment.BUNDLE_PARAM_USER_INFO);  

//		pageString = i.getStringExtra("page");
//       if(null==mCurAccount)
//       {
//		retrieveAccountListData();
//		refreshDeviceSetting();	
//      }
		
		setContentView(R.layout.health_cards_overview_activity);
		healthTabtitle =(TextView) findViewById(R.id.title);
		healthTabtitle.setText(mCurAccount.nick);
		ImageView back = (ImageView) findViewById(R.id.back);
		back.setOnClickListener(this);
		
		ImageView set = (ImageView) findViewById(R.id.set);
		set.setOnClickListener(this);
		
		mLoadingProgress = (ProgressBar) findViewById(R.id.loading_progress);
		mLoadingProgress.setVisibility(View.GONE);
		

		loaded = false;

		//initReceiver();
        InitWidth();
        InitTextView();
        InitViewPager();
   
	}
	

	private void initReceiver()
	{
		IntentFilter filter = new IntentFilter();
		filter.addAction(DataManager.DATA_UPDATE_ACTION);
		registerReceiver(mReceiver, filter);		
	}
	
	
	private void refreshAccountList(){
//		HashMap<String,String> oldmap = new HashMap<String,String>();
//		for(MULTI_USER_DEV_DATA d:mAccountListData){
//			String key = d.id+"-"+d.subcode;
//			oldmap.put(key, key);
//		}
		
//		retrieveAccountListData();
///		refreshDeviceSetting();
//		boolean updateAll = false;
//		for(MULTI_USER_DEV_DATA d:mAccountListData){
//			String key = d.id+"-"+d.subcode;
//			String v = oldmap.get(key);
//			if(v != null){
//				oldmap.remove(key);
//			}else{
//				updateAll = true;
//				break;
//			}
//		}
		
//		if(updateAll){
			//new account found
//			loaded = false;
//			buildCard();
//			startLoading();
//		}else{
//			if(oldmap.size() > 0){
				//one or more account deleted
//				loaded = false;
//				buildCard();
//				startLoading();
//			}else{
//				updateFragments();
//				mAdapter.notifyDataSetChanged();
//			}
//		}
	}

	private void updateFragments(){
//		int size = mAccountListData.size();
//		
//		for(DEV_DATA d:mAccountListData){
//			HealthCardFragment f = mFragmentMap.get(d.id);
//			if(f != null){
//				Bundle args = new Bundle();
//				args.putInt("total", size);
//				args.putSerializable("account", d);
//				f.updateArgs(args);
//			}
//		}
	}
	
	
	
	private void retrieveGlycoseListData(){

	}

	private void buildCard(){

	}


	
	private final int MSG_LOADING_TIMEOUT = 221;
	
	private Handler mhandler = new Handler(){
		@Override
		public void handleMessage(Message msg){
			switch(msg.what){
			case MSG_LOADING_TIMEOUT:{
				loadingFinish();
			}
			break;
			}
		}
	};
	
	private void loadingFinish(){
		loaded = true;
		mhandler.removeMessages(MSG_LOADING_TIMEOUT);
		mLoadingProgress.setVisibility(View.GONE);

	}
	
	private void startLoading(){
		

		loadingFinish();
	}
	


	
	@Override
	public void onSaveInstanceState(Bundle b){
		//must keep this override to avoid fragment leak
	}

	@Override
	public void onResume(){
		super.onResume();

		if(!loaded){
			startLoading();
		}else{
			refreshAccountList();
		}
		initReceiver();
	}
	
	@Override
	public void onPause(){
		super.onPause();
		logd("onPause");
		unregisterReceiver(mReceiver);
		mhandler.removeMessages(MSG_LOADING_TIMEOUT);
	}
	
	@Override
	public void onDestroy(){
//		mPages.clear();
//		mFragmentMap.clear();
		super.onDestroy();
	}
	
	private boolean hasFragmentIsRefreshing(){
		if(fragmentBloodSugar != null)
		{	
				return ((HealthCardBloodSugarOverViewFragment)fragmentBloodSugar).isRefreshing();
		}	
		return false;
	}
	
	private void stopRefreshing(){
	}
	
	@Override
    public boolean onKeyDown(int keyCode, KeyEvent event){
	   	
	   	if(keyCode == KeyEvent.KEYCODE_BACK){
	   		if(hasFragmentIsRefreshing()){
	   			stopRefreshing();
	   			return true;
	   		}
	   	}
	   	return super.onKeyDown(keyCode,event);
    }
	
	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.back:{
			finish();
		}break;
		case R.id.set:{
//			if(mAccountListData.size()>0){
//				mCurAccount = mAccountListData.get(mCurAccount.index);
				Intent i = new Intent(this,SettingActivity.class);
				i.putExtra("from", "health_card");
				i.putExtra("dev", mCurAccount);
				startActivityForResult(i, RESULT_CODE_CARD_SETTINGS);
//			}
		}break;
		}
		
	}
	
	private int RESULT_CODE_CARD_SETTINGS = 33;
	@Override
	public void onActivityResult(int code, int ret, Intent intent){
		if(RESULT_CODE_CARD_SETTINGS == code){
			if(ret == RESULT_OK){
				
				
			}
		}
	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPageSelected(int pos) {
		
	}

	private void refreshDeviceSetting(){

	}

	
	
    private void InitTextView() {
    	healthTabBloodSugar = (TextView) findViewById(R.id.health_tab_bloodsugar);
    	healthTabPressure = (TextView) findViewById(R.id.health_tab_bloodpressure);
//    	healthTabSleep = (TextView) findViewById(R.id.health_tab_sleep);
    	healthTabTemperature = (TextView) findViewById(R.id.health_tab_temperature);
//    	healthTabWeight = (TextView) findViewById(R.id.health_tab_weight);
    	

    	healthTabBloodSugar.setOnClickListener(new MyOnClickListener(0));
    	healthTabPressure.setOnClickListener(new MyOnClickListener(1));
    	healthTabTemperature.setOnClickListener(new MyOnClickListener(2));

    	
//    	healthTabBloodSugar.setOnClickListener(new MyOnClickListener(0));
//    	healthTabPressure.setOnClickListener(new MyOnClickListener(1));
//    	healthTabSleep.setOnClickListener(new MyOnClickListener(2));
//    	healthTabTemperature.setOnClickListener(new MyOnClickListener(3));
//    	healthTabWeight.setOnClickListener(new MyOnClickListener(4));

    }

    public class MyOnClickListener implements View.OnClickListener {
        private int index = 0;

        public MyOnClickListener(int i) {
            index = i;
        }

        @Override
        public void onClick(View v) {
            mPager.setCurrentItem(index);
        }
    }; 
    
    
    
    
    private void InitViewPager() {
        mPager = (ViewPager) findViewById(R.id.slider_pager);
        fragmentsList = new ArrayList<Fragment>();
        int bgcolor =0xFF444444;
        int fgcolor =0xFFff7b06;
 //       getndayGlyData(1); //��ȡ1������
         fragmentBloodSugar    =      new HealthCardBloodSugarOverViewFragment();
         Bundle args = new Bundle();
         args.putSerializable("account", mCurAccount);    
         fragmentBloodSugar.setArguments(args);

         fragmentBloodPressure =      new HealthCardBloodPressureOverViewFragment(mApp);
         fragmentBloodPressure.setArguments(args);
//        Fragment fragmentSleep         =      new HealthCardSleepOverViewFragment();
//        Fragment fragmentWeight        =      new HealthCardWeightOverViewFragment();
         fragmentTemperature   =      new HealthCardTemperatureOverViewFragment();

        fragmentsList.add(fragmentBloodSugar);
        currIndex = 0;
        fragmentsList.add(fragmentBloodPressure);
        if(pageString.equalsIgnoreCase("fragmentBloodPressure")){
        	currIndex = 1;
        	healthTabBloodSugar.setTextColor(bgcolor);
        	healthTabPressure.setTextColor(fgcolor);
//        	healthTabSleep.setTextColor(bgcolor);
        	healthTabTemperature.setTextColor(bgcolor);
//        	healthTabWeight.setTextColor(bgcolor);
        }
        fragmentsList.add(fragmentTemperature);
        if(pageString.equalsIgnoreCase("fragmentTemperature")){
        	currIndex = 2;
        	healthTabBloodSugar.setTextColor(bgcolor);
        	healthTabPressure.setTextColor(bgcolor);
//        	healthTabSleep.setTextColor(bgcolor);
        	healthTabTemperature.setTextColor(fgcolor);
//        	healthTabWeight.setTextColor(bgcolor);
        }  
/*        
        fragmentsList.add(fragmentSleep);
        if(pageString.equalsIgnoreCase("fragmentSleep")){
        	currIndex = 3;
        	healthTabBloodSugar.setTextColor(bgcolor);
        	healthTabPressure.setTextColor(bgcolor);
        	healthTabSleep.setTextColor(fgcolor);
        	healthTabTemperature.setTextColor(bgcolor);
        	healthTabWeight.setTextColor(bgcolor);
        }

        fragmentsList.add(fragmentWeight);
        if(pageString.equalsIgnoreCase("fragmentWeight")){
        	currIndex = 4;
        	healthTabBloodSugar.setTextColor(bgcolor);
        	healthTabPressure.setTextColor(bgcolor);
        	healthTabSleep.setTextColor(bgcolor);
        	healthTabTemperature.setTextColor(bgcolor);
        	healthTabWeight.setTextColor(fgcolor);
        }
        
*/        
        mPager.setAdapter(new HealthCardFragmentPagerAdapter(getSupportFragmentManager(), fragmentsList));
        mPager.setCurrentItem(currIndex);
        mPager.setOnPageChangeListener(new HealthCardFragmentOnPageChangeListener());
        updateBottomLinePosition(currIndex);
    }

    public class HealthCardFragmentPagerAdapter extends FragmentPagerAdapter {
        private ArrayList<Fragment> fragmentsList;

        public HealthCardFragmentPagerAdapter(android.support.v4.app.FragmentManager fm) {
            
        	//@Override
        	super(fm);
        }

        public HealthCardFragmentPagerAdapter(android.support.v4.app.FragmentManager fm, ArrayList<Fragment> fragments) {
            super(fm);
            this.fragmentsList = fragments;
        }

        @Override
        public int getCount() {
            return fragmentsList.size();
        }

        @Override
        public Fragment getItem(int arg0) {
            return fragmentsList.get(arg0);
        }

        @Override
        public int getItemPosition(Object object) {
            return super.getItemPosition(object);
        }

    }
    
  
    
    
    public class HealthCardFragmentOnPageChangeListener implements OnPageChangeListener {

        @Override
        public void onPageSelected(int arg0) {
            Animation animation = null;
            
            int bgcolor =0xFF444444;
            int fgcolor =0xFFff7b06;
            
            switch (currIndex) {
			case 0:{
				if(currIndex != arg0)
					((HealthCardBloodSugarOverViewFragment) fragmentBloodSugar).focusChange(false);
			}break;
			
			case 1:{
				if(currIndex != arg0)
					((HealthCardBloodPressureOverViewFragment) fragmentBloodPressure).focusChange(false);
			}break;

			case 2:{
				if(currIndex != arg0)
					((HealthCardTemperatureOverViewFragment) fragmentTemperature).focusChange(false);
			}break;
			}
            
            switch (arg0) {
            case 0:
                if (currIndex == 0) {
                    animation = new TranslateAnimation(0, 0, 0, 0);
                    healthTabBloodSugar.setTextColor(bgcolor);
                }
                else
                if (currIndex == 1) {
                    animation = new TranslateAnimation(position_one, 0, 0, 0);
                    healthTabPressure.setTextColor(bgcolor);
                }
                else if (currIndex == 2) {
                animation = new TranslateAnimation(position_two, 0, 0, 0);
                healthTabTemperature.setTextColor(bgcolor);
                }                
/*                
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_three, 0, 0, 0);
                    healthTabSleep.setTextColor(bgcolor);
                } else if (currIndex == 3) {
                    animation = new TranslateAnimation(position_four, 0, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }
                 else if (currIndex == 4) {
                   animation = new TranslateAnimation(position_five, 0, 0, 0);
                   healthTabWeight.setTextColor(bgcolor);
                }   
*/                                
                healthTabBloodSugar.setTextColor(fgcolor);
                ((HealthCardBloodSugarOverViewFragment) fragmentBloodSugar).focusChange(true);
                break;
            case 1:
                if (currIndex == 0) {
                    animation = new TranslateAnimation(0, position_one, 0, 0);
                    healthTabBloodSugar.setTextColor(bgcolor);
                }
                else if (currIndex == 1) {
                    animation = new TranslateAnimation(position_one, position_one, 0, 0);
                    healthTabPressure.setTextColor(bgcolor);
                }
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_two, position_one, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }                
 /*               
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_two, position_one, 0, 0);
                    healthTabSleep.setTextColor(bgcolor);
                } else if (currIndex == 3) {
                    animation = new TranslateAnimation(position_three, position_one, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }
                 else if (currIndex == 4) {
                   animation = new TranslateAnimation(position_four, position_one, 0, 0);
                   healthTabWeight.setTextColor(bgcolor);
                }     
*/                           
                healthTabPressure.setTextColor(fgcolor);
                ((HealthCardBloodPressureOverViewFragment) fragmentBloodPressure).focusChange(true);
                break;
                
            case 2:
                if (currIndex == 0) {
                    animation = new TranslateAnimation(0, position_two, 0, 0);
                    healthTabBloodSugar.setTextColor(bgcolor);
                }
                else if (currIndex == 1) {
                    animation = new TranslateAnimation(position_one, position_two, 0, 0);
                    healthTabPressure.setTextColor(bgcolor);
                }
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_two, position_two, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }
                
                healthTabTemperature.setTextColor(fgcolor);
                ((HealthCardTemperatureOverViewFragment) fragmentTemperature).focusChange(true);
                break;                
                
                

/*               
            case 2:
                if (currIndex == 0) {
                    animation = new TranslateAnimation(0, position_two, 0, 0);
                    healthTabBloodSugar.setTextColor(bgcolor);
                }
                else if (currIndex == 1) {
                    animation = new TranslateAnimation(position_one, position_two, 0, 0);
                    healthTabPressure.setTextColor(bgcolor);
                }
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_two, position_two, 0, 0);
                    healthTabSleep.setTextColor(bgcolor);
                } else if (currIndex == 3) {
                    animation = new TranslateAnimation(position_three, position_two, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }
                 else if (currIndex == 4) {
                   animation = new TranslateAnimation(position_four, position_two, 0, 0);
                   healthTabWeight.setTextColor(bgcolor);
                }   
               
                healthTabSleep.setTextColor(fgcolor);
                
                break;
            case 3:
                if (currIndex == 0) {
                    animation = new TranslateAnimation(0, position_three, 0, 0);
                    healthTabBloodSugar.setTextColor(bgcolor);
                }
                else if (currIndex == 1) {
                    animation = new TranslateAnimation(position_one, position_three, 0, 0);
                    healthTabPressure.setTextColor(bgcolor);
                }
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_two, position_three, 0, 0);
                    healthTabSleep.setTextColor(bgcolor);
                } else if (currIndex == 3) {
                    animation = new TranslateAnimation(position_three, position_three, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }
                 else if (currIndex == 4) {
                   animation = new TranslateAnimation(position_four, position_three, 0, 0);
                   healthTabWeight.setTextColor(bgcolor);
                }   
                
                healthTabTemperature.setTextColor(fgcolor);

                break;
            case 4:
                if (currIndex == 0) {
                    animation = new TranslateAnimation(0, position_four, 0, 0);
                    healthTabBloodSugar.setTextColor(bgcolor);
                }
                else if (currIndex == 1) {
                    animation = new TranslateAnimation(position_one, position_four, 0, 0);
                    healthTabPressure.setTextColor(bgcolor);
                }
                else if (currIndex == 2) {
                    animation = new TranslateAnimation(position_two, position_four, 0, 0);
                    healthTabSleep.setTextColor(bgcolor);
                } else if (currIndex == 3) {
                    animation = new TranslateAnimation(position_three, position_four, 0, 0);
                    healthTabTemperature.setTextColor(bgcolor);
                }
                 else if (currIndex == 4) {
                   animation = new TranslateAnimation(position_four, position_four, 0, 0);
                   healthTabWeight.setTextColor(bgcolor);
                }   
                healthTabWeight.setTextColor(fgcolor);

                break;     
*/                           
            }
            currIndex = arg0;
            animation.setFillAfter(true);
            animation.setDuration(300);
            ivBottomLine.startAnimation(animation);
        }


        
        
        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    }
 
    public void updateBottomLinePosition(int currIndex)
    {  
        Animation animation = null;
        animation = new TranslateAnimation(0, position_one*currIndex, 0, 0);
        animation.setFillAfter(true);
        animation.setDuration(300);
        ivBottomLine.startAnimation(animation);
    }   
    
    
    private void InitWidth() {
        ivBottomLine = (ImageView) findViewById(R.id.iv_bottom_line);
        bottomLineWidth = ivBottomLine.getLayoutParams().width;
        Log.d(TAG, "cursor imageview width=" + bottomLineWidth);
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        int screenW = dm.widthPixels;
        offset = (int) ((screenW / TATAL_TAB_INDEX - bottomLineWidth) / 2);
        Log.i("XXXXXX InitWidth", "offset=" + offset);

        position_one = (int) (screenW / TATAL_TAB_INDEX);
        position_two = position_one +position_one;
        position_three = position_two +position_one;
        position_four = position_three +position_one;
 //       position_five = position_four +position_one;

        
    }	

    
 	private BroadcastReceiver mReceiver = new BroadcastReceiver(){
		@Override
		public void onReceive(Context context, Intent intent) {
			String action = intent.getAction();
			boolean isFinish = intent.getBooleanExtra("isFinish", false);

			if(action.equals(DataManager.DATA_UPDATE_ACTION)){
				String t = intent.getStringExtra("type");
				if(t.equals(DataManager.F_GLYCOSE_DATA) ){

					String tid = intent.getStringExtra("tid");
					String subcode = intent.getStringExtra("subcode");
//					long earliest = intent.getLongExtra("earliest", 0);
                    
					if(tid.equals(tid) && subcode.equals(subcode)&& isFinish)
					{
//						String[]  args;//
//						args = new String[2];
//						args[0] = tid;
//						args[1] = subcode;

                        
						if(fragmentBloodSugar!=null)
						{	
               ((HealthCardBloodSugarOverViewFragment) fragmentBloodSugar).refreshResult(DataManager.F_GLYCOSE_DATA,isFinish);
//							((HealthCardBloodSugarOverViewFragment) fragmentBloodSugar).UpdateGlycoseData(args);
						}

					}
					
				}
				if(t.equals(DataManager.F_GLYCOSE_SET) ){

 					String tid = intent.getStringExtra("tid");
                   
					if(tid.equals(tid) )
					{
                        
						if(fragmentBloodSugar!=null)
						{	
               ((HealthCardBloodSugarOverViewFragment) fragmentBloodSugar).refreshResult(DataManager.F_GLYCOSE_SET,isFinish);
//							((HealthCardBloodSugarOverViewFragment) fragmentBloodSugar).UpdateGlycoseData(args);
						}

					}
					
				}				
				if(t.equals(DataManager.F_BP_DATA)){
					String tid = intent.getStringExtra("tid");
					String subcode = intent.getStringExtra("subcode");
					if(tid.equals(tid) && subcode.equals(subcode)&& isFinish){
						if(fragmentBloodPressure != null){
							((HealthCardBloodPressureOverViewFragment)fragmentBloodPressure).refreshResult(DataManager.F_BP_DATA, isFinish);
						}
					}
				}
			}
		}
	};
	    
    
    
    
}
